#include<bits/stdc++.h>
using namespace std;
int n, x, A, B;
vector<int>t[100005];
int dep[100005];
int dfn[100005], rnk[100005], cnt;
int fa[100005], sz[100005];
void dfs(int now){
    dfn[now] = ++cnt;
    rnk[cnt] = now;
    sz[now] = 1;
    for(auto to : t[now]){
        if(!dep[to]){
            fa[to] = now;
            dep[to] = dep[now] + 1;
            dfs(to);
            sz[now] += sz[to];
        }
    }
}
int dp[100005];
int st[100005][20];
int getmin(int l, int r){
    if(l > r)return 1e9;
    int len = __lg(r - l + 1);
    return min(st[l][len], st[r - (1<<len) + 1][len]);
}
int f[400005];
void chg(int now, int l, int r, int x){
    if(l == r){
        f[now] = dp[x];
        return;
    }
    int mid = l+r>>1;
    if(x <= mid)chg(now * 2, l, mid, x);
    else chg(now * 2 + 1, mid + 1, r, x);
    f[now] = min(f[now * 2], f[now * 2 + 1]);
}
int qry(int now, int l, int r, int x, int y){
    if(x <= l && r <= y)return f[now];
    int mid = l+r>>1;
    int ans = 1e9;
    if(x <= mid)ans = min(ans, qry(now * 2, l, mid, x, y));
    if(y > mid)ans = min(ans, qry(now * 2 + 1, mid + 1, r, x, y));
    return ans;
}
void bf1(){
    dep[x] = 1;
    dfs(x);
    for(int i = 1; i <= n; i++)st[i][0] = rnk[i];
    for(int j = 1; j < 20; j++){
        for(int i = 1; i + (1<<j) - 1 <= n; i++){
            st[i][j] = min(st[i][j - 1], st[i + (1<<j-1)][j - 1]);
        }
    }
    memset(f, 0x3f, sizeof(f));
    for(int i = n; i >= 1; i--){
        if(i + A > n){
            dp[i] = getmin(i, min(n, i + B));
        }else{
            dp[i] = qry(1, 1, n, i + A, min(n, i + A + B));
            dp[i] = min(dp[i], getmin(max(1, i+A - B), i+A - 1));
        }
        chg(1, 1, n, i);
    }
    cout << dp[1] << '\n';
}
int g[3005];
vector<int>p;
void dfs(int now, int yq){
    if(dep[now] == yq)p.emplace_back(now);
    for(auto to : t[now]){
        if(dep[to] == dep[now] + 1){
            dfs(to, yq);
        }
    }
}
int c[3005];
void solve(int x){
    for(auto to : t[x]){
        if(dep[to] == dep[x] + 1){
            solve(to);
        }
    }
    p.clear();
    dfs(x, dep[x] + A);
    f[x] = 0;
    for(int i = 1; i < t[x].size(); i++)c[i] = 0;
    if(!p.size()){
        int z = 1;
        f[x] = x;
        for(int _ = dfn[x]+1; _ < dfn[x] + sz[x]; _++){
            int i = rnk[_];
            if(dep[i] - dep[x] <= B){
                f[x] = min(f[x], i);
                if(sz[t[x][z]] + dfn[t[x][z]] - 1 < dfn[i])z++;
                if(!c[z])c[z] = i;
                else c[z] = min(c[z], i);
            }
        }
        int mn = 1e9, pl = -1;
        for(int i = 1; i < t[x].size(); i++){
            if(mn > c[i]){
                mn = c[i];
                pl = i;
            }
        }
        for(int i = 1; i < t[x].size(); i++){
            if(i == pl){
                int mn = 1e9;
                for(int j = 1; j < t[x].size(); j++){
                    if(i == j)continue;
                    mn = min(mn, c[j]);
                }
                g[t[x][i]] = min(x,mn);
            }else{
                g[t[x][i]] = f[x];
            }
        }
    }else{
        int z = 1;
        for(auto i : p){
            int res = 1e9;
            for(int j = dfn[i]; j < dfn[i] + sz[i]; j++){
                if(dep[rnk[j]] - dep[i] <= B){
                    res = min(res, f[rnk[j]]);
                }
            }
            int nw = i;
            int pre = nw;
            while(1){
                nw = fa[nw];
                if(dep[i] - dep[nw] > B)break;
                for(int j = dfn[nw] + 1; j < dfn[pre]; j++){
                    if(dep[j] - dep[nw] <= B - (dep[i] - dep[nw])){
                        res = min(res, f[rnk[j]]);
                    }
                }
                for(int j = dfn[pre] + sz[pre]; j < dfn[nw] + sz[nw]; j++){
                    if(dep[j] - dep[nw] <= B - (dep[i] - dep[nw])){
                        res = min(res, f[rnk[j]]);
                    }
                }
                if(t[nw].size() == 2){
                    assert(g[pre] == nw);
                }
                res = min(res, g[pre]);
                pre = nw;
            }
            f[x] = max(f[x], res);
            if(sz[t[x][z]] + dfn[t[x][z]] - 1 < dfn[i])z++;
            c[z] = max(c[z], res);
        }
        int mx = 0, pl = -1;
        for(int i = 1; i < t[x].size(); i++){
            if(mx < c[i]){
                mx = c[i];
                pl = i;
            }
        }
        for(int i = 1; i < t[x].size(); i++){
            if(i == pl){
                int mx = 0;
                for(int j = 1; j < t[x].size(); j++){
                    if(i == j)continue;
                    mx = max(mx, c[j]);
                }
                if(mx == 0)g[t[x][i]] = t[x][i];
                else g[t[x][i]] = mx;
            }else{
                g[t[x][i]] = f[x];
            }
            if(dfn[t[x][i]] <= dfn[p[0]] && dfn[p.back()] < dfn[t[x][i]] + sz[t[x][i]]){
                g[t[x][i]] = x;
                for(int j = 1; j < t[x].size(); j++){
                    if(i == j)continue;
                    for(int k = dfn[t[x][j]]; k < dfn[t[x][j]] + sz[t[x][j]]; k++){
                        if(dep[rnk[k]] - dep[x] <= B){
                            g[t[x][i]] = min(g[t[x][i]], rnk[k]);
                        }
                    }
                }
            }
        }
        
    }
    // cerr << x << "::" << '\n';
    // cerr << f[x] << '\n';
    // for(int i = 1; i < t[x].size(); i++){
    //     cerr << t[x][i] << ":" << g[t[x][i]] << '\n';
    // }
}
void bf2(){
    dep[x] = 1;
    dfs(x);
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < t[i].size(); j++){
            if(t[i][j] == fa[i]){
                for(int k = j; k >= 1; k--){
                    t[i][k] = t[i][k - 1];
                }
                t[i][0] = fa[i];
                break;
            }
        }
        for(int j = 2; j < t[i].size(); j++){
            assert(dfn[t[i][j-1]]+sz[t[i][j-1]] == dfn[t[i][j]]);
        }
    }
    solve(x);
    cout << f[x] << '\n';
}
signed main(){
    freopen("nim.in", "r", stdin);
    freopen("nim.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n >> x >> A >> B;
    if(A <= B){
        cout << 1 << '\n';
        return 0;
    }
    for(int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        t[u].emplace_back(v);
        t[v].emplace_back(u);
    }
    int mx = 0;
    for(int i = 1; i <= n; i++)mx = max(mx, (int)t[i].size());
    if(mx == 2 && t[x].size() == 1){
        bf1();
        return 0;
    }
    if(n <= 3000){
        bf2();
        return 0;
    }
    return 0;
}